package main

import (
	"fmt"
	"sensitives/service/dic"
	"strings"
)

type Sensitive struct {
	Word  string
	Start int
	End   int
}

var SenitiveWord []Sensitive

func main() {
	dic.LoadDic()
	SenitiveWord = make([]Sensitive, 0)
	site_10001 := dic.CloudMap[10001].Sys
	fmt.Println(site_10001)
	texts := strings.Split("你色你项目", "")
	texts_length := len(texts)
	for i := 0; i < texts_length; i++ {
		tmpText := texts[i]
		TempMap := &site_10001
		if _, ok := TempMap.Node[tmpText]; !ok {
			continue
		}
		TempMap = TempMap.Node[tmpText]
		if TempMap.IsEnd {
			sensi := Sensitive{
				Word:  tmpText,
				Start: i,
				End:   i + 1,
			}
			SenitiveWord = append(SenitiveWord, sensi)
		}
		for j := i + 1; j < texts_length; j++ {
			jtext := texts[j]
			Tmpj, ok := TempMap.Node[jtext]
			if !ok {
				break
			} else if ok && Tmpj.IsEnd {
				tmpText += jtext
				sensi := Sensitive{
					Word:  tmpText,
					Start: i,
					End:   j,
				}
				SenitiveWord = append(SenitiveWord, sensi)
				TempMap = Tmpj
			}
		}
	}
	fmt.Println(SenitiveWord)
}
